package com.iot.server.enumeration;

import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @author wuzt
 * Date 2019/10/28 15:21
 * Version 1.0
 * @ClassName TimeEnum
 * Description
 **/
public enum TimeEnum {
    /**
     * 创建时间
     */
    CREATETIME(0, "CREATETIME"),

    /**
     * 更新时间
     */
    UPDATETIME(1, "UPDATETIME"),

    /**
     * 创建and更新时间
     */
    CREATETIME_UPDATETIME(2, "CREATETIME_UPDATETIME");

    TimeEnum(int code, String value) {
        this.code = code;
        this.value = value;
    }

    private int code;
    private String value;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public static TimeEnum fromTimeEnum(String name) {
        if (!StringUtils.isBlank(name)) {
            for (TimeEnum en : TimeEnum.values()) {
                if (name.equals(en.getValue())) {
                    return en;
                }
            }
        }
        return null;
    }

    public static List<String> getValueList() {
        List<String> valueList = new ArrayList<>();
        for (TimeEnum en : TimeEnum.values()) {
            valueList.add(en.getValue());
        }
        return valueList;
    }
}
